/* ajax of wechat*/
export default class Ajax {
	constructor() {
		this.baseURI = "http://172.18.3.6/"
	}

	get(_url, _data) {
		let self = this
		return new Promise((resolve, reject) => {
			wx.request({
				url: self.baseURI + _url,
				data: _data,
				header: {
					'content-type': 'application/x-www-form-urlencoded',
				},
				success: res => {
					resolve(res.data)
				},
				fail: err => {
					console.log('请求失败！', err)
					reject(err)
				}
			})
		})
	}

	post(_url, _data) {
		let self = this
		return new Promise((resolve, reject) => {
			wx.request({
				url: self.baseURI + _url,
				data: _data,
				header: {
					'Content-Type':'application/x-www-form-urlencoded',
				},
				method: 'POST',
				success: res => {
					resolve(res.data)
				},
				fail: err => {
					console.log('请求失败！', err)
					reject(err)
				}
			})
		})
	}
}